package com.ys.controller.api.kefu;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.controller.web.hr.WebThrOperateCompanyBeianController;
import com.ys.entity.kefu.TkfKnow;
import com.ys.service.kefu.TkfKnowService;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.LayuiTableVoJA;
import com.ys.vo.R;

@Controller
@RequestMapping("/api/inter/tkfKnow")
public class ApiInterTkfKnowController {
	
//	private static final Logger logger = Logger.getLogger(ApiAdminLoginController.class);
	
	@Autowired
	private CommonApiService<TkfKnow> commonApiService;
	@Autowired
	private TkfKnowService tkfKnowService;

	@RequiresPermissions("tkfKnow:view")
	@RequestMapping("/search")
    @ResponseBody
	public LayuiTableVoJA search(Model model, HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute TkfKnow cond
			){
		
		return commonApiService.searchLay(cond);
	}
	
//	/**
//	 * 新增
//	 */
//	@RequiresPermissions("tkfKnow:add")
//	@PostMapping("/add")
//    @ResponseBody
//	public R add(HttpServletRequest request, @RequestParam Map<String, Object> params){
//		try {
//			return tkfKnowService.add(params, ApiInterThrOperateCompanyBeianController.MENU_ID);
//		} catch (Exception e) {
//			e.printStackTrace();
//			return R.error("系统正在开小差，请联系客服，我们将第一时间为您解决！");
//		}
//	}
	
	/**
	 * 编辑
	 */
	@RequiresPermissions("tkfKnow:edit")
	@PostMapping("/edit")
    @ResponseBody
	public R edit(HttpServletRequest request, @RequestParam Map<String, Object> params){
		try {
			return tkfKnowService.edit(params);
		} catch (Exception e) {
			e.printStackTrace();
			return R.error("系统正在开小差，请联系客服，我们将第一时间为您解决！");
		}
	}
	
	/**
	 * 删除
	 */
	@RequiresPermissions("tkfKnow:edit")
	@PostMapping("/deleteTrue")
    @ResponseBody
	public R deleteTrue(HttpServletRequest request, Long id){
		try {
			return tkfKnowService.deleteTrue(id);
		} catch (Exception e) {
			e.printStackTrace();
			return R.error("服务器正在开小差，请联系客服");
		}
	}
}
